<template>
	<div id='hisProcessRecord' style="height: 100%">
		<span class="timeline-title">{{customTitle}}</span>
		<el-timeline>
      <el-timeline-item placement="top" icon="el-icon-check" v-for="item in  state.sort1 ? state.sortData1 : state.hisProcessRecordData1"
        :key="item.taskId" color="#25b113">
				<el-descriptions :column="1">
					<el-descriptions-item label="审批人：">
						<strong>{{item.assigneeName}}</strong>
					</el-descriptions-item>
					<el-descriptions-item label="节点：">
						{{item.taskName}}
					</el-descriptions-item>
					<el-descriptions-item label="处理状态：">
						{{dataDictionaryFilter(item.taskState, state.dataDictionaryList['ProcessRecordState'] )}}
					</el-descriptions-item>
					<el-descriptions-item label="处理结果：">
						{{dataDictionaryFilter(item.description, state.dataDictionaryList['processResult'])}}
					</el-descriptions-item>
					<el-descriptions-item label="处理意见：">
						{{item.approveAdvice}}
					</el-descriptions-item>
					<el-descriptions-item label="开始时间：">{{item.startTime ? formatDate(new Date(item.startTime), 'YYYY-mm-dd HH:MM:SS') : ''}}</el-descriptions-item>
					<el-descriptions-item label="结束时间：">{{item.endTime ? formatDate(new Date(item.endTime), 'YYYY-mm-dd HH:MM:SS') : ''}}</el-descriptions-item>
					<el-descriptions-item label="附件："></el-descriptions-item>
				</el-descriptions>
			</el-timeline-item>
		</el-timeline>
	</div>
</template>
<script setup lang="ts" name="approveHisDetailFoot">
import { onMounted, reactive } from 'vue';
import { getDataDictionaryList } from '/@/utils/cacheDic';
import { formatDate } from '/@/utils/formatTime'
import { TaskVo, workflowApi } from '/@/api/sys/workflow-api'

const props = defineProps({
	processId: {
		type: String,
		default: () => '0'
	},
	customTitle: {
		type: String,
		default: () => {
			return '处理记录'
		}
	}
})
const state = reactive({
	dataDictionaryList: {} as any,
	sort1: false,
	hisProcessRecordData1: [] as TaskVo[],
	sortData1: [] as TaskVo[],
	viewUploadVisible: false,
})
// 页面加载时
onMounted(() => {
	// 数据字典
	getDataDictionaryList(state.dataDictionaryList, ["ProcessRecordState", "processResult"])
	// 列表查询
	workflowApi.getHisTaskByProcessId(props.processId).then((data) => {
		if (data.code === 0) {
			state.hisProcessRecordData1 = data.data
			state.hisProcessRecordData1.forEach(val => {
				state.sortData1.unshift(val)
			})
		}
	}).catch(() => {})
})
//数据字典回显
const dataDictionaryFilter = (msg: any, obj: any) => {
	if (obj) {
		return obj.get(msg)
	}
}
</script>
<style scoped lang="scss">
</style>